var _excluded = [
  'pathname',
  'base',
  'trigger',
  'headerRender',
  'title',
  'logo',
  'theme',
  'width',
  'collapsed',
  'onCollapse',
  'drilled',
  'onReturn',
];
function _extends() {
  _extends = Object.assign
    ? Object.assign.bind()
    : function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];
          for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }
        return target;
      };
  return _extends.apply(this, arguments);
}
function _objectWithoutProperties(source, excluded) {
  if (source == null) return {};
  var target = _objectWithoutPropertiesLoose(source, excluded);
  var key, i;
  if (Object.getOwnPropertySymbols) {
    var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
    for (i = 0; i < sourceSymbolKeys.length; i++) {
      key = sourceSymbolKeys[i];
      if (excluded.indexOf(key) >= 0) continue;
      if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
      target[key] = source[key];
    }
  }
  return target;
}
function _objectWithoutPropertiesLoose(source, excluded) {
  if (source == null) return {};
  var target = {};
  var sourceKeys = Object.keys(source);
  var key, i;
  for (i = 0; i < sourceKeys.length; i++) {
    key = sourceKeys[i];
    if (excluded.indexOf(key) >= 0) continue;
    target[key] = source[key];
  }
  return target;
}
import RollbackOutlined from '@ant-design/icons/RollbackOutlined';
import { Layout } from 'antd';
import 'antd/es/layout/style/index.js';
import classnames from 'classnames';
import React, { useMemo } from 'react';
import { Link } from 'react-router-dom';
import Menus from '../Menus';
import './index.less';
var Sider = Layout.Sider;

/**
 * 侧边栏展示模式
 */

/**
 * 侧边栏
 */

/**
 * 侧边栏
 * @param param0
 * @returns
 */
export default function CustomSider(_ref) {
  var _rest$sensitive;
  var pathname = _ref.pathname,
    _ref$base = _ref.base,
    base = _ref$base === void 0 ? '/' : _ref$base,
    trigger = _ref.trigger,
    headerRender = _ref.headerRender,
    title = _ref.title,
    logo = _ref.logo,
    _ref$theme = _ref.theme,
    theme = _ref$theme === void 0 ? 'dark' : _ref$theme,
    _ref$width = _ref.width,
    width = _ref$width === void 0 ? 256 : _ref$width,
    collapsed = _ref.collapsed,
    onCollapse = _ref.onCollapse,
    _ref$drilled = _ref.drilled,
    drilled = _ref$drilled === void 0 ? false : _ref$drilled,
    onReturn = _ref.onReturn,
    rest = _objectWithoutProperties(_ref, _excluded);
  /** 默认头部 */
  var defaultHeader = useMemo(
    function () {
      if (drilled) {
        return /*#__PURE__*/ React.createElement(
          'div',
          {
            className: 'szzj-sider-header szzj-sider-return',
            onClick: function onClick() {
              onReturn === null || onReturn === void 0 ? void 0 : onReturn();
            },
          },
          /*#__PURE__*/ React.createElement(
            'span',
            {
              className: classnames('szzj-menu-return-icon', {
                collapsed: !!collapsed,
              }),
            },
            /*#__PURE__*/ React.createElement(RollbackOutlined, null),
          ),
          /*#__PURE__*/ React.createElement(
            'a',
            {
              className: classnames('szzj-sider-header-title', {
                collapsed: !!collapsed,
              }),
            },
            '\u8FD4\u56DE',
          ),
        );
      }
      var shown = collapsed ? title && logo : title || logo;
      return shown
        ? /*#__PURE__*/ React.createElement(
            Link,
            {
              to: base,
            },
            /*#__PURE__*/ React.createElement(
              'div',
              {
                className: 'szzj-sider-header',
              },
              logo &&
                /*#__PURE__*/ React.createElement('span', {
                  className: 'szzj-sider-header-logo',
                  style: {
                    background: 'url('.concat(logo, ') center center no-repeat'),
                    backgroundSize: 'cover',
                  },
                }),
              title &&
                /*#__PURE__*/ React.createElement(
                  'span',
                  {
                    className: classnames('szzj-sider-header-title', {
                      collapsed: !!collapsed,
                    }),
                  },
                  title,
                ),
            ),
          )
        : null;
    },
    [base, title, logo, drilled, onReturn, collapsed, history],
  );
  return /*#__PURE__*/ React.createElement(
    Sider,
    {
      breakpoint: 'lg',
      className: 'szzj-sider',
      collapsible: true,
      trigger: trigger,
      collapsed: collapsed,
      onCollapse: onCollapse,
      theme: theme,
      width: width,
    },
    headerRender ? headerRender(defaultHeader) : defaultHeader,
    /*#__PURE__*/ React.createElement(
      'div',
      {
        className: 'szzj-sider-menus',
      },
      /*#__PURE__*/ React.createElement(
        Menus,
        _extends(
          {
            pathname: pathname,
            base: base,
            theme: theme,
          },
          rest,
          {
            sensitive: collapsed
              ? false
              : (_rest$sensitive = rest.sensitive) !== null && _rest$sensitive !== void 0
              ? _rest$sensitive
              : true,
          },
        ),
      ),
    ),
  );
}
